package com.example.userserver.controller;

import com.example.userserver.params.LoginParams;
import com.example.userserver.params.RegisterParams;
import com.example.userserver.service.AccountService;
import com.example.userserver.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user-server")
@Api(tags = "账号相关接口")
public class AccountController {
    @Autowired
    private AccountService accountService;
    @ApiOperation(value = "登录接口")
    @PostMapping(value = "/login")
    public Result login(@RequestBody LoginParams loginParams) {
        return accountService.login(loginParams);
    }

    @ApiOperation(value = "注册接口")
    @PostMapping(value = "/register")
    public Result register(@RequestBody RegisterParams registerParams) {
        return accountService.register(registerParams);
    }

    @ApiOperation(value = "验证token")
    @PostMapping(value = "/check")
    public Boolean check(@RequestParam("token") String token) {
        return accountService.checkToken(token);
    }

    @ApiOperation(value = "验证是否冻结")
    @GetMapping(value = "/checkFreeze")
    public Result checkFreeze(@RequestParam("id") String id) {
        return accountService.checkFreeze(id);
    }

}
